﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using AP.Framework.Infrastructure.Repositories.IRepositories;
using AP.Framework.Infrastructure.Entities;

namespace AP.Web.Areas.Admin.Controllers
{
    public class DefaultController : Controller
    {
        IParam _param;
        public DefaultController(IParam param)
        {
            _param = param;
        }
        public ActionResult Index()
        {
            if (Session["UserName"] != null)
            {
                sys_Param model = _param.GetAll().SingleOrDefault();
                if (model != null)
                {
                    Session["SiteName"] = model.SiteName;
                    Session["CompanyName"] = model.CompanyName;
                    Session["CompanyLog"] = model.CompanyLog;
                    Session["CopyRight"] = model.CopyRight;
                }
                return View();
            }
            else
            {
                return RedirectToAction("Logon", "Account", new { area = "" });
            }
        }

        //
        // GET: /Admin/Default/Deta ils/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /Admin/Default/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /Admin/Default/Create

        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Admin/Default/Edit/5

        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /Admin/Default/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Admin/Default/Delete/5

        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /Admin/Default/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
